package cn.edu.zafu.bigdata.x.zcy_0217;
/*
import java.io.*;
import java.util.*;

public class StudentManagementSystem {
    private static final String FILE_NAME = "students.dat";
    private static Map<String, Student> studentMap = new HashMap<>();

    public static void main(String[] args) {
        loadStudents();
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("======= 学生信息管理系统 =======");
            System.out.println("1. 添加学生信息");
            System.out.println("2. 检索学生信息");
            System.out.println("3. 更新学生信息");
            System.out.println("4. 删除学生信息");
            System.out.println("5. 退出程序");
            System.out.print("请输入操作编号 (1-5): ");

            String choice = scanner.nextLine();
            switch (choice) {
                case "1":
                    addStudent(scanner);
                    break;
                case "2":
                    searchStudent(scanner);
                    break;
                case "3":
                    updateStudent(scanner);
                    break;
                case "4":
                    deleteStudent(scanner);
                    break;
                case "5":
                    saveStudents();
                    System.out.println("程序已退出。");
                    return;
                default:
                    System.out.println("无效选项，请重新输入。");
            }
        }
    }

    private static void addStudent(Scanner scanner) {
        System.out.println("===== 添加学生信息 =====");
        while (true) {
            System.out.print("请输入学号 (或输入 QUIT 返回): ");
            String id = scanner.nextLine();
            if ("QUIT".equalsIgnoreCase(id)) break;

            if (studentMap.containsKey(id)) {
                System.out.println("学号已存在，请重新输入。");
                continue;
            }

            System.out.print("请输入姓名: ");
            String name = scanner.nextLine();
            System.out.print("请输入电话: ");
            String phone = scanner.nextLine();

            studentMap.put(id, new Student(id, name, phone));
            System.out.println("学生信息添加成功！");
        }
    }

    private static void searchStudent(Scanner scanner) {
        System.out.println("===== 检索学生信息 =====");
        while (true) {
            System.out.print("请输入学号 (或输入 QUIT 返回): ");
            String id = scanner.nextLine();
            if ("QUIT".equalsIgnoreCase(id)) break;

            Student student = studentMap.get(id);
            if (student == null) {
                System.out.println("未找到该学生。");
            } else {
                System.out.println(student);
            }
        }
    }

    private static void updateStudent(Scanner scanner) {
        System.out.println("===== 更新学生信息 =====");
        while (true) {
            System.out.print("请输入学号 (或输入 QUIT 返回): ");
            String id = scanner.nextLine();
            if ("QUIT".equalsIgnoreCase(id)) break;

            Student student = studentMap.get(id);
            if (student == null) {
                System.out.println("未找到该学生。");
            } else {
                System.out.print("请输入新的姓名: ");
                String newName = scanner.nextLine();
                System.out.print("请输入新的电话: ");
                String newPhone = scanner.nextLine();

                student.setName(newName);
                student.setPhone(newPhone);
                System.out.println("学生信息更新成功！");
            }
        }
    }

    private static void deleteStudent(Scanner scanner) {
        System.out.println("===== 删除学生信息 =====");
        while (true) {
            System.out.print("请输入学号 (或输入 QUIT 返回): ");
            String id = scanner.nextLine();
            if ("QUIT".equalsIgnoreCase(id)) break;

            if (studentMap.remove(id) == null) {
                System.out.println("未找到该学生。");
            } else {
                System.out.println("学生信息删除成功！");
            }
        }
    }

    private static void loadStudents() {
        try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(FILE_NAME))) {
            studentMap = (Map<String, Student>) ois.readObject();
        } catch (FileNotFoundException e) {
            // 文件不存在是正常情况，首次运行时会创建
        } catch (IOException | ClassNotFoundException e) {
            System.err.println("加载学生信息失败: " + e.getMessage());
        }
    }

    private static void saveStudents() {
        try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(FILE_NAME))) {
            oos.writeObject(studentMap);
            System.out.println("学生信息已保存。");
        } catch (IOException e) {
            System.err.println("保存学生信息失败: " + e.getMessage());
        }
    }
}

class Student implements Serializable {
    private static final long serialVersionUID = 1L;
    private String id;
    private String name;
    private String phone;

    public Student(String id, String name, String phone) {
        this.id = id;
        this.name = name;
        this.phone = phone;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getPhone() {
        return phone;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Override
    public String toString() {
        return "学号: " + id + ", 姓名: " + name + ", 电话: " + phone;
    }


}
        */